package com.qulai.web.controller.amazon_us;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.qulai.common.annotation.Log;
import com.qulai.common.core.controller.BaseController;
import com.qulai.common.core.domain.AjaxResult;
import com.qulai.common.enums.BusinessType;


import com.qulai.amazon_us.domain.amazon_us.BasicProductMap;
import com.qulai.amazon_us.service.amazon_us.IBasicProductMapService;

import com.qulai.common.utils.poi.ExcelUtil;
import com.qulai.common.core.page.TableDataInfo;

/**
 * 亚马逊us-库存价格映射Controller
 * 
 * @author hunan
 * @date 2025-06-10
 */
@RestController
@RequestMapping("/amazon_us/map")
public class BasicProductMapController extends BaseController
{
    @Autowired
    private IBasicProductMapService basicProductMapService;

    /**
     * 查询亚马逊us-库存价格映射列表
     */
    @PreAuthorize("@ss.hasPermi('amazon_us:map:list')")
    @GetMapping("/list")
    public TableDataInfo list(BasicProductMap basicProductMap)
    {
        startPage();
        List<BasicProductMap> list = basicProductMapService.selectBasicProductMapList(basicProductMap);
        return getDataTable(list);
    }

    /**
     * 导出亚马逊us-库存价格映射列表
     */
    @PreAuthorize("@ss.hasPermi('amazon_us:map:export')")
    @Log(title = "亚马逊us-库存价格映射", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasicProductMap basicProductMap)
    {
        List<BasicProductMap> list = basicProductMapService.selectBasicProductMapList(basicProductMap);
        ExcelUtil<BasicProductMap> util = new ExcelUtil<BasicProductMap>(BasicProductMap.class);
        util.exportExcel(response, list, "亚马逊us-库存价格映射数据");
    }

    /**
     * 获取亚马逊us-库存价格映射详细信息
     */
    @PreAuthorize("@ss.hasPermi('amazon_us:map:query')")
    @GetMapping(value = "/{basicId}")
    public AjaxResult getInfo(@PathVariable("basicId") Long basicId)
    {
        return success(basicProductMapService.selectBasicProductMapByBasicId(basicId));
    }

    /**
     * 新增亚马逊us-库存价格映射
     */
    @PreAuthorize("@ss.hasPermi('amazon_us:map:add')")
    @Log(title = "亚马逊us-库存价格映射", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasicProductMap basicProductMap)
    {
        return toAjax(basicProductMapService.insertBasicProductMap(basicProductMap));
    }

    /**
     * 修改亚马逊us-库存价格映射
     */
    @PreAuthorize("@ss.hasPermi('amazon_us:map:edit')")
    @Log(title = "亚马逊us-库存价格映射", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasicProductMap basicProductMap)
    {
        return toAjax(basicProductMapService.updateBasicProductMap(basicProductMap));
    }

    /**
     * 删除亚马逊us-库存价格映射
     */
    @PreAuthorize("@ss.hasPermi('amazon_us:map:remove')")
    @Log(title = "亚马逊us-库存价格映射", businessType = BusinessType.DELETE)
	@DeleteMapping("/{basicIds}")
    public AjaxResult remove(@PathVariable Long[] basicIds)
    {
        return toAjax(basicProductMapService.deleteBasicProductMapByBasicIds(basicIds));
    }
}
